<template>
  <div class="warp" flex="dir:top box:first">
    <div>
      <div class="title" flex="main:justify cross:center">
        当前报警列表
        <router-link to="/village/msgset/33">
          <el-button v-if="deptId === '33'" type="text">
            报警设置
            <i class="el-icon-setting el-icon--right"></i>
          </el-button>
        </router-link>
      </div>
      <div class="list-thead">
        <table>
          <col width="40%">
          <col width="60%">
          <!--<col width="25%" />-->
          <!--<col width="25%" />-->
          <thead>
            <tr>
              <td>场景</td>
              <td>报警时间</td>
              <!--<td>地址</td>-->
              <!--<td>状态</td>-->
            </tr>
          </thead>
        </table>
      </div>
    </div>

    <ul class="list" v-if="mapList.length !== 0">
      <li v-for="(item,index) in mapList" :key="index" flex="dir:left" @click="alarmShow(item)">
        <div class="w-40 list-title" :title="item.moduleName">{{item.moduleName}}</div>
        <div class="w-60">{{item.eventTime}}</div>
        <!--<div class="text-overflow w-25" :title="item.eventContent">{{item.eventContent}}</div>-->
        <!--<div class="w-25">临时车辆</div>-->
      </li>
    </ul>
    <div class="list-no" v-else>暂无报警记录</div>
  </div>
</template>
<script>
import { mapState } from 'vuex'

export default {
  name: 'alarm-list',
  props: ['deptId'],
  data () {
    return {
      mapList: [] // 报警数据列表
    }
  },
  computed: {
    ...mapState({
      warnAllData: state => state.event.warnAllData
    })
  },
  watch: {
    deptId (val) {
      this.init()
    }
  },
  mounted () {
    this.init()
  },
  methods: {
    // 初始化
    init () {
      if (!this.deptId) {
        return
      }

      let _this = this
      let url = this.$base.getUrl('getEventListByDeptId')

      let params = {
        url: url,
        data: {
          deptId: this.deptId
        }
      }

      this.$store.dispatch('getForm', params).then(res => {
        _this.$store.commit('setWarnAllData', res)
        _this.mapList = res
      })
    },
    // 在地图上显示警告详情
    alarmShow: function (item) {
      let map = this.$store.state.event.supMap
      map.moveToDot(item.eventSysId)
    }
  }
}
</script>
<style lang="less" scoped>
.w-60 {
  width: 60%;
}

.w-40 {
  width: 40%;
}

.w-30 {
  width: 30%;
}

.w-20 {
  width: 20%;
}

.w-25 {
  width: 25%;
}

.text-overflow {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.warp {
  .title {
    color: #fff;
    font-size: 14px;
  }
  padding: 20px 15px;
  height: 100%;
  box-sizing: border-box;
}

.list-thead {
  margin-top: 15px;
  overflow-x: hidden;
  width: 100%;
  table {
    width: 100%;
    td {
      text-align: center;
    }
    thead {
      background-color: rgba(0, 0, 0, 0.2);
      width: 100%;
      height: 24px;
      line-height: 24px;
      font-size: 12px;
      color: #50e3c2;
      letter-spacing: 0.29px;
    }
  }
}

.list {
  margin-top: 10px;
  overflow-x: hidden;
  overflow-y: scroll;
  width: 100%;
  text-align: center;
  color: #9facc3;
  .list-title {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
  li {
    cursor: pointer;
    width: 100%;
    height: 30px;
    line-height: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
}

.list-no {
  margin-top: 10px;
  text-align: center;
  color: #9facc3;
}

.list::-webkit-scrollbar {
  width: 0 !important;
}

//chrome 和Safari
.list {
  -ms-overflow-style: none;
}

//IE 10+
.list {
  overflow: -moz-scrollbars-none;
}

//Firefox
</style>
